import java.io.*;
import java.util.*;

public class OStSolution{
    
    Scanner in;
    PrintWriter out;
    
    void solve() {
		int n = in.nextInt();
		int place[] = new int[n];
		boolean used[] = new boolean[n];
		for (int i = 0; i < n; i++) {
			int pos = in.nextInt() - 1;
			place[i] = pos;
		}
		int answer = 0;
		for (int i = 0; i < used.length; i++) {
			if (!used[i] && place[i]!=i) {
				int next = i;
                                int chainSize = 0;
				while (true) {
                                        chainSize++;
					used[next] = true;
					next = place[next];
					if (used[next]) {
						break;
					}
				}
				answer+=chainSize+1;
			}
		}
		out.println(answer);
	}
    
    void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}
    
    
    public static void main(String args[]){
        new OStSolution().run();
    }
    
}
